package com.logreview;

import com.logreview.consumer.LoggerConsumer;
import com.logreview.produce.LoggerProduce;
import com.logreview.util.ContextUtil;
import com.logreview.util.CoreSocketClient;
import com.logreview.util.FileUtil;
import com.logreview.util.OfepClient;
import com.logreview.vo.LoggerVO;
import com.logreview.vo.Monitor;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Component
public class ApplicationConfig {

    private org.slf4j.Logger logger = LoggerFactory.getLogger(ApplicationConfig.class);


    @Autowired
    ApplicationProperties applicationProperties;

    @Autowired
    ArrayBlockingQueue<LoggerVO> blockingQueue;

    @Bean
    public ArrayBlockingQueue<LoggerVO> blockingQueue(){
        return new ArrayBlockingQueue<LoggerVO>(applicationProperties.getQueueSize());
    }

    @Bean
    @Scope("prototype")
    public LoggerProduce loggerProduce(){
        return new LoggerProduce(blockingQueue);
    }

    @Bean
    @Scope("prototype")
    public LoggerConsumer loggerConsumer(){
        return new LoggerConsumer(blockingQueue);
    }

    @Bean
    public ContextUtil contextUtil(){
        return new ContextUtil();
    }

    @Bean
    @Scope("prototype")
    public CoreSocketClient coreSocketClient(){
        return new CoreSocketClient(applicationProperties.getHdsGatewayIpAddress(),applicationProperties.getService4CorePort());
    }

    @Bean
    public OfepClient ofepClient(){
        return new OfepClient();
    }

    @Bean
    public ApplicationInit applicationInit(){
        return new ApplicationInit();
    }
}
